using System.Collections.Generic;
using Headsight.BPMN2WF.BPMN.Model;

namespace Headsight.BPMN2WF.Testing.TestObjCtors
{
    /// <summary>
    /// <see cref="BPMNProcessFactoryParams"/> <see cref="ITestObjCtor{T}"/>.
    /// </summary>
    public class BPMNModelFactoryParamsCtor : ITestObjCtor<BPMNProcessFactoryParams>
    {
        private IList<BPMNArgument> _bpmnProcArgs;
        private IList<BPMNFlowNode> _bpmnFlowNodes;
        private IList<BPMNSequenceFlow> _bpmnSeqFlows;
        private BPMNArgumentFactory _bpmnModelFactory;

        public BPMNProcessFactoryParams Create()
        {
            var bpmnModelFactoryBpmnSequenceFlow = 
                new BPMNModelFactoryBPMNSequenceFlowCtor().With(_bpmnSeqFlows).Create();
            var bpmnModelFactoryBPMNFlowNode = 
                new BPMNModelFactoryBPMNFlowNodeCtor().With(_bpmnFlowNodes).Create();
            var bpmnModelFactoryBpmnArgument = _bpmnModelFactory ??
                new BPMNModelFactoryBPMNArgumentCtor().WithBPMNProcessArguments(_bpmnProcArgs).Create();
            
            return new BPMNProcessFactoryParams(bpmnModelFactoryBpmnSequenceFlow, bpmnModelFactoryBPMNFlowNode,
                                                    bpmnModelFactoryBpmnArgument);
        }

        public BPMNModelFactoryParamsCtor WithBPMNProcessArguments(IList<BPMNArgument> bpmnProcArgs)
        {
            _bpmnProcArgs = bpmnProcArgs;

            return this;
        }

        public BPMNModelFactoryParamsCtor WithBPMNFlowNodes(IList<BPMNFlowNode> bpmnFlowNodes)
        {
            _bpmnFlowNodes = bpmnFlowNodes;

            return this;
        }

        public BPMNModelFactoryParamsCtor WithBPMNSequenceFlows(IList<BPMNSequenceFlow> bpmnSeqFlows)
        {
            _bpmnSeqFlows = bpmnSeqFlows;

            return this;
        }

        public BPMNModelFactoryParamsCtor With(BPMNArgumentFactory bpmnMFacArgs)
        {
            _bpmnModelFactory = bpmnMFacArgs;

            return this;
        }
    }
}